import java.util.Random;

/**
 * A class representing a weapon with a hit probability and random damage.
 * 
 * @author Malcolm Ryan
 * @version Aug 2 2011
 */
public class Weapon
{
    private int myHitProb;
    private int myMaxDamage;
    private Random myRNG;

    /**
     * Create a new weapon with a 
     */
    public Weapon(int hitProb, int damage) {
        myHitProb = hitProb;
        myMaxDamage = damage;
        myRNG = new Random();
    }

    public boolean hit() {
        
        int r = myRNG.nextInt(100);
        
        if (r < myHitProb) {
            return true;
        }
        else {
            return false;
        }
    }
    
    public int damage() {
        int dam = myRNG.nextInt(myMaxDamage) + 1;        
        return dam;
    }
}
